package com.smart.campus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.campus.dao.ShCheckMapper;
import com.smart.campus.dto.ShCheck;
import com.smart.campus.pojo.PagedResponse;
import com.smart.campus.service.ShCheckService;
import com.smart.campus.util.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongsProject: smart-campus
 * @BelongsPackage: com.smart.campus.service.impl
 * @Author: 戴冰洁
 * @CreateTime: 2024-10-08  14:04
 * @Description: TODO
 * @Version: 1.0
 */
@Service
public class ShCheckServiceImpl implements ShCheckService {
    @Autowired
    private ShCheckMapper shCheckMapper;

    @Override
    public List<ShCheck> findshcheck() {
        return shCheckMapper.selectList(null);
    }

    @Override
    public void addshcheck(ShCheck shCheck) {
        shCheckMapper.insert(shCheck);
    }

    @Override
    public void deletebyid(Integer id) {
        shCheckMapper.deleteById(id);
    }

    @Override
    public ShCheck shcheckList(Integer id) {
     return shCheckMapper.selectById(id);
    }

    @Override
    public void updateshcheck(ShCheck shCheck) {
        shCheckMapper.updateById(shCheck);
    }

    @Override
    public PagedResponse<ShCheck> pageShChenck(ShCheck shCheck, Integer pageNUm, Integer pageSize) {
        Page<ShCheck> page = new Page<>(pageNUm, pageSize);
        QueryWrapper<ShCheck> queryWrapper = new QueryWrapper<>();
        IPage<ShCheck> page1 = shCheckMapper.pageShChenck(page,queryWrapper);
        return PaginationUtil.getPaginationResponse(page1.getRecords(),pageNUm,pageSize,page1.getTotal());
    }
}
